﻿#define _CRT_SECURE_NO_WARNINGS
#include"test.h"
void menu()
{
	printf("*****************************\n");
	printf("***********  1.play   *******\n");
	printf("***********  0.exit   *******\n");
	printf("*****************************\n");

}
void game()
{
	char ret;
	char board[ROW][COL] = { 0 };
	init(board, ROW, COL);
	show_board(board, ROW, COL);
	while (1)
	{

		p_move(board, ROW, COL);
		system("cls");
		show_board(board, ROW, COL);
		ret = win(board, ROW, COL);
		if (ret != 'c')
			break;
		c_move(board, ROW, COL);
		show_board(board, ROW, COL);
		ret = win(board, ROW, COL);
		if (ret != 'c')
			break;
	}
	if (ret == '*')
	{
		system("cls");
		printf("恭喜你，获胜！\n");
		show_board(board, ROW, COL);

	}
	else if (ret == '#')
	{
		system("cls");
		printf("很遗憾，你输了！\n");
		show_board(board, ROW, COL);

	}

	else if (ret == 'Q')
	{
		system("cls");
		printf("平局！\n");
		show_board(board, ROW, COL);
	}


}
int main()
{
	int input = 0;
	srand((unsigned int)time(NULL));
	do
	{
		menu();
		printf("请选择:>");
		scanf("%d", &input);
		switch (input)
		{
		case 1:
			game();
			break;
		case 0:
			break;
		default:
			printf("输入错误，请重新输入！\n");
		}

	} while (input);

	return 0;
}